package cn.ltgodm.moj.judge.codesandbox;

import cn.hutool.json.JSONUtil;
import cn.ltgodm.moj.judge.codesandbox.model.ExecuteCodeRequest;
import cn.ltgodm.moj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 静态代理增强代码沙箱
 */
@Slf4j
public class CodesandboxProxy implements CodeSandbox{

    private final CodeSandbox codeSandbox;

    public CodesandboxProxy(CodeSandbox codeSandbox){
        this.codeSandbox = codeSandbox;
    }


    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求信息：{}", JSONUtil.toJsonStr(executeCodeRequest));
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("代码沙箱返回响应：{}", JSONUtil.toJsonStr(executeCodeResponse));
        return executeCodeResponse;
    }
}
